package genealogy.deprecated.datamodel.pedigree.comparator;

import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
import edu.byu.cs.dml.recordlinkage.stringmetrics.EnsembleCJMN;
import genealogy.deprecated.datamodel.pedigree.Name;

/**
 * @author Steve
 * @invariant
 */
@Deprecated
public class NameComparator {

	private AbstractStringMetric m_stringComparator; // = new EnsembleCJMN();

	private double m_defaultValue = .8;
	
	/**
	 * Constructor
	 * 
	 * @pre
	 * @post the object is created
	 */
	public NameComparator() {
		m_stringComparator = new EnsembleCJMN();
	}

	public Double compareNames(Name name1, Name name2) {
		if (name1 == null || name2 == null)
		{
			return null;
		}

		if (name1.getName().length() == 0 || name2.getName().length() == 0)
		{
			return null;
		}
		double score = (double) m_stringComparator.getSimilarity(name1.getName(), name2
				.getName());
		
		return score * score;
	}

	public Double compareNames(String name1, String name2) {
		if (name1 == null || name2 == null)
		{
			return null;
		}

		return (double) m_stringComparator.getSimilarity(name1, name2);
	}
	
	/**
	 * Getter for the defaultValue
	 * @return the defaultValue
	 * @pre none
	 * @post result is not null
	 */
	public double getDefaultValue() {
		return m_defaultValue;
	}

	/**
	 * Setter for the defaultValue
	 * @param defaultValue the defaultValue to set
	 * @pre defaultValue != null
	 * @post the defaultValue is set on this instance
	 */
	public void setDefaultValue(double defaultValue) {
		m_defaultValue = defaultValue;
	}

}
